﻿@using Seal.Model
@using Seal.Helpers
@{
    ReportView view = Model;
    ReportModel reportModel = view.Model;
    Report report = view.Report;

    var elementMenuCount = view.GetNumericValue("model_menu_element_count");
}

<script>
    $(document).ready(function () {
        $("#report_body_container").css("display", "block");
        $('#tc_@(view.IdSuffix) li:eq(@view.GetNumericValue("model_menu_index")) a').tab('show');
        $('#tc_@(view.IdSuffix) a').click(function (e) {
            if (@Helper.ToJS(report.GenerateHTMLDisplay)) processSubmitViewParameter("model_menu_index", $($(this).attr('href'), '@view.ViewId').index());
            @if (report.HasNVD3Chart)
            {<text>
            redrawNVD3Charts();
            </text>
            }
            redrawDataTables();
        });
    });
</script>


@if (reportModel.Pages.Count > 1 && !report.PrintLayout && view.GetValue("model_menu_type") != "none")
{
    <ul id="tc_@(view.IdSuffix)" class="nav nav-@(view.GetValue("model_menu_style"))s @(view.GetValue("model_menu_type") != "top" ? "nav-stacked" : "")  @(view.GetBoolValue("model_menu_justified") ? "nav-justified" : "")">
        @if (view.GetBoolValue("show_summary_table"))
        {
            <li class="active"><a data-toggle="@view.GetValue("model_menu_style")" href='#@(view.IdSuffix + "_summary")'>@report.Translate("Summary")</a></li>
        }
        @for (int row = 1; row <reportModel.SummaryTable.RowCount && row < reportModel.Pages.Count + 1; row++)
        {
            ResultPage page = reportModel.Pages[row - 1];
            string val = "";
            for (int col = 0; col < (elementMenuCount == 0 ? reportModel.SummaryTable.ColumnCount : elementMenuCount); col++)
            {
                ResultCell cell = reportModel.SummaryTable[row, col];
                if (!cell.IsTotal)
                {
                    val += string.IsNullOrEmpty(val) ? "" : ",";
                    val += cell.DisplayValue;
                }
            }
            if (view.GetBoolValue("model_show_count")) val += $" ({page.DataTable.BodyEndRow - page.DataTable.BodyStartRow})";

            <li class='@(row==1 && !view.GetBoolValue("show_summary_table") ? "active" :"")'>
                <a data-toggle="@view.GetValue("model_menu_style")" href='#@(view.IdSuffix + page.PageId)'>@Raw(val)</a>
            </li>
        }
    </ul>
}
